package com.edu.whty.service.impl;

import com.edu.whty.dao.TbLabelMapper;
import com.edu.whty.entity.comment.LabelReq;
import com.edu.whty.entity.comment.ResourcLabel;
import com.edu.whty.entity.comment.TbLabel;
import com.edu.whty.service.LabelService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service("labelService")
public class LabelServiceImpl implements LabelService {

	private Logger logger = LoggerFactory.getLogger(getClass());

	@Autowired
	TbLabelMapper tblabelMapper;

	/**
	 * 保存资源关联的标签
	 */
	@Override
	public void saveResourceLabel(LabelReq label) {
		TbLabel tbLabel = new TbLabel();
		tbLabel.setBusinessId(label.getBusinessId());
		tbLabel.setId(label.getLabelId());
		tbLabel.setUserId(label.getUserId());
		tbLabel.setPlatformCode(label.getPlatformCode());
		tbLabel.setCreateTime(new Date());
		tbLabel.setUpdateTime(new Date());
		tbLabel.setLoginPlatformCode(label.getLoginPlatformCode());
		
		tblabelMapper.saveLabelResource(tbLabel);
	}
	/**
	 *  标签列表
	 */
	@Override
	public List<ResourcLabel> getResourceLabelList(LabelReq label){
		Map<String,String> map  = new HashMap<String,String>();
		
		map.put("loginPlatformCode", label.getLoginPlatformCode());
		map.put("businessType", label.getBusinessType());
		map.put("businessId", label.getBusinessId());
		List<ResourcLabel> resList =  tblabelMapper.queryLabelResource(label);
		return resList;
	}
}
